package com.kitty.record.kittyio.bio.two;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;
import java.util.Scanner;

/**
 * @Description
 * @Author SHEN
 * @Date 2021/2/8
 */
public class Client {

    public static void main(String[] args) {

        OutputStream outputStream = null;
        PrintStream printStream = null;

        try {
            Socket socket = new Socket("127.0.0.1",9999);

           outputStream = socket.getOutputStream();

            printStream = new PrintStream(outputStream);

            Scanner scanner = new Scanner(System.in);
            while (true){

                System.out.println("请输入：");

                printStream.println(scanner.nextLine());
                printStream.flush();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {

            if(printStream != null){
                printStream.close();
            }

            if(outputStream != null){
                try {
                    outputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }

    }


}
